﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using RestSharp;
using WeiTalk.SinaEntities.Friendships;
using WeiTalk.OAuth;

namespace WeiTalk.Interfaces.Sina
{
    public class FriendshipsAPI : WeiBoAPIs
    {
        const string friendsUrl = "https://api.weibo.com/2/friendships/friends.json";
        public FriendshipsAPI(RestClient client) : base(client) { }

        public void GetFriends(Action<IRestResponse<Collection>> callback, string uid = null, string screen_name = null, int cursor = 0, int trim_status = 1)
        {
            RestRequest request = new RestRequest(friendsUrl, Method.GET);
            request.AddParameter("source", Utility.ConsumerKey);
            request.AddParameter("access_token", Utility.AccessToken.Token);
            request.AddParameter("count", Constant.WeiBoCount-1);
            if (!String.IsNullOrEmpty(uid))
            {
                request.AddParameter("uid", uid);
            }
            if (!String.IsNullOrEmpty(screen_name))
            {
                request.AddParameter("screen_name", screen_name);
            }
            if (cursor > 0)
            {
                request.AddParameter("cursor", cursor);
            }
            request.AddParameter("trim_status", trim_status);
            request.AddParameter("timestamp", Guid.NewGuid().ToString());
            Client.ExecuteAsync<Collection>(request, callback);
        }
    }
}
